package dhm.com.dhmshop.updata.activity;

import android.os.Bundle;
import android.widget.TextView;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import dhm.com.dhmshop.R;
import dhm.com.dhmshop.base.BaseActiity;
import dhm.com.dhmshop.base.Presenter.PressenterImpl;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.base.netWork.LoginContract;
import dhm.com.dhmshop.entity.MessageDetail;
import dhm.com.dhmshop.utils.SpUtils;

public class MessagedetailActivity extends BaseActiity implements LoginContract.IView {

    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.content)
    TextView content;

    PressenterImpl pressenter;


    @Override
    protected int getLayout() {
        return R.layout.activity_messagedetail;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        pressenter=new PressenterImpl();
        pressenter.attachView(this);

        String uid = SpUtils.getString(this, "uid");
        String msgId = getIntent().getStringExtra("msgId");
        Map<String,String> map=new HashMap<>();
        map.put("token", Constant.TOKEN);
        map.put("msgId",msgId);
        map.put("uid", uid);
        pressenter.sendMessage(this,Constant.GetMessageInfo,map, MessageDetail.class);


    }

    @Override
    protected void initData() {

    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void requesta(Object data) {
        if (data instanceof MessageDetail){
            MessageDetail messageDetail= (MessageDetail) data;
            if (messageDetail.getCode()==1){
                time.setText(messageDetail.getData().getCreateTime());
                content.setText(messageDetail.getData().getMsgContent());
            }
        }
    }

    @Override
    public void fail(String error) {

    }
}
